//
//  DownMusicModel.h
//  MiBaoTu
//
//  Created by 邹奥 on 16/9/25.
//  Copyright © 2016年 com.caesartech15. All rights reserved.
//
#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger,DownMusicState) {
    DownMusicState_Start = 0,       //开始下载
    DownMusicState_Suspended,       //下载暂停
    DownMusicState_Completed,       //下载完成
    DownMusicState_Failed           //下载失败
};

typedef void (^DownLoadProgressBlock)(CGFloat progress,NSString *speed, NSString *remainingTime, NSString *writtenSize, NSString *totalSize);
typedef void (^DownLoadStatsBlock)(DownMusicState stats);

@interface DownMusicModel : NSObject<NSCoding>

/** 下载进度 */
@property (atomic, copy) DownLoadProgressBlock progressBlock;

/** 下载状态 */
@property (atomic, copy) DownLoadStatsBlock stateBlock;

/** 流 */
@property (nonatomic, strong) NSOutputStream *stream;

/** 下载地址 */
@property (nonatomic, copy) NSString *url;
/** 开始下载时间 */
@property (nonatomic, strong) NSDate *startTime;
/** 文件名 */
@property (nonatomic, copy) NSString *fileName;
/** 文件大小 */
@property (nonatomic, copy) NSString *totalSize;
/**音频文件ID**/
@property (nonatomic, copy) NSString *musicID;
/**音频文件类型**/
@property (nonatomic, copy) NSString *musicType;  //1、2、3、4、5.1、5.2
@property (nonatomic, copy) NSString *isDowning;  //是否正在下载状态

@property (nonatomic, copy) NSString *userID;  //发布认ID
@property (nonatomic, copy) NSString *content; //感受
@property (nonatomic, copy) NSString *picUrl;  //图片地址
@property (nonatomic, copy) NSString *date;    //日期
@property (nonatomic, copy) NSString *userPic; //头像
@property (nonatomic, copy) NSString *userNick;  //昵称
@property (nonatomic, copy) NSString *size;    //大小

/** 获得服务器这次请求 返回数据的总长度 */
@property (nonatomic, assign) NSInteger totalLength;

//长度转换成大小
- (float)calculateFileSizeInUnit:(unsigned long long)contentLength;
- (NSString *)calculateUnit:(unsigned long long)contentLength;
@end
